<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class WechatUser extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;
    /**
     * 默认排序
     */
    protected $defaultSortCriteria = ['id,desc'];

    /**
     * 可排序字段
     */
    public $sortable = [
        'created_at',
        'id',
        'user_id',
        'nickname',
        'sex',
        'city',
        'province',
        'country',
        'group_id',
        'user_type',
        'country',
        'country',
        'country',
    ];

    /**
     * 可搜索字段
     */
    public $searchable = [
        'user_id',
        'nickname',
        'sex',
        'city',
        'province',
        'country',
        'group_id',
        'second',
        'user_type',
        'phone',
        'qq_number',
        'created_at'

    ];
    /**
     * 微信用户表可批量复制的字段
     */
    protected $fillable =[
        'user_id',
        'unionid',
        'openid',
        'nickname',
        'avatar',
        'sex',
        'city',
        'language',
        'province',
        'country',
        'remark',
        'group_id',
        'tagid_list',
        'subscribe',
        'subscribe_time',
        'second',
        'user_type',
        'password',
        'phone',
        'qq_number',
    ];
    /**
     * 用户所在分组
     */
    public function userGroup(){
        return $this->belongTos(UserGroup::class,'group_id','id');
    }
    /**
     *
     */
}
